<template>
    <div class="sing-index">
        <div class="top">
            <button @touchstart="backPage"><i class="iconfont icon-zuojiantou"></i></button>
            <h3>{{singerData.singerName}}</h3>
        </div>
        <div class="singImg">

            <div class="img-part">
                <img :src="singerData.bg" alt="">
            </div>
            
            <p class="title">{{singerData.singerName}}</p> 
        </div>

        <div class="singer-text">
            {{singerData.text}}
        </div>

        <recommend-songs :songData="songDataList" v-on="$listeners">
            <template v-slot:titleText>
                热门歌曲
            </template>
        </recommend-songs>
    </div>
</template>

<script>
import recommendSongs from '@/components/recommend-songs.vue'
export default {
  components: { recommendSongs },
  data(){
      return {
          singerData : {},
          songDataList : []
      }
  },
  watch : {

  }
  ,
    created(){
        this.singerData.bg = this.$route.query.bg;
        this.singerData.singerName = this.$route.query.singerName;
        this.singerData.text = this.$route.query.text;
        axios.get(`/api/artist/top/song?id=${this.$route.query.id}&limit=9`).then(response=>{
            let newArr = [];
            newArr.push(response.data.songs.splice(0,9));
            newArr[0].forEach(item => {
                let obj = {};
                let newObj = {};
                newObj.name = this.singerData.singerName;
                obj.id = item.id;
                obj.name = item.name;
                obj.picUrl = item.al.picUrl;
                obj.song = {};
                obj.song.artists = [];
                obj.song.artists.push(newObj);
                this.songDataList.push(obj);
            })
        })
    },
    methods : {
        backPage(){
          this.$router.go(-1);
      }
    }
}
</script>

<style lang="scss" scoped>
    .sing-index {
        width: 100%;
        padding: 2.7rem 0rem 10rem 0rem;
    }

    .singImg {
        width: 100%;
        position: relative;
    }

    .img-part {
        width: 100%;
        min-height: 10rem;
        
        >img {
            width: 100%;
            filter: blur(1px);
        }
    }

    .title {
        position: absolute;
        left: 1.5rem;
        bottom: 1rem;
        font-size: 2rem;
        font-weight: bolder;
        color: #fff;
    }

    .singer-text {
        width: 90%;
        margin: auto;
        font-size: 0.9rem;
        height: 5rem;
        line-height: 1.5rem;
        overflow-y:auto;
        border: 1px solid #ccc;
        border-radius: 0.5rem;
        padding: 0.5rem;
        margin-top: 0.2rem;
    }

     .top {
            display: flex;
            background: rgba(233, 233, 233, 1);
            position: fixed;
            top: 2.5rem;
            width: 100%;
            z-index: 4;

            >h3 {
                width: 95%;
                margin: auto;
                padding: 1rem 0rem;
                font-size: 1.3rem;
                font-weight: bolder;
            }

            >button {
                display: block;
                width: 2rem;
                text-align: center;
                margin: auto;
                border: none;
                background: transparent;

                .icon-zuojiantou {
                    font-size: 1.5rem;
                }
            }
        }
    
</style>